 <template>
	<view class="search-input">
		<view class="uni-form-item uni-column">
			<view class="">请输入赠送人号码：</view>
			<input v-model="phone" type="number" />
			<view class="">请选择优惠券：</view>
			<picker @change="bindPickerChange" :value="index" :range="array" range-key="name">
				<view class="input">{{couponname}}</view>
			</picker>
			<view class="">优惠金额：￥<text style="color: crimson;font-size: 40rpx;font-weight: 600;">{{couponvalue}}</text> </view>
		</view>
		<button style="margin-top: 30rpx;" @click="addbtn()">赠送</button>
		<!-- 底部teb栏 -->
		<TabBar currentPage="index"></TabBar>
	</view>
</template>

<script>
	import TabBar from '@/pages/common/components/TabBar.vue'
	import { couponsQueryAll,saveSpecificUcoupon  } from '@/api/shop.js'
	export default {
		data () {
			return {
				array: [],
				couponname:'',
				couponId:'',
				phone:'',
				couponvalue:''
			}
		},
		components: {
			TabBar
		},
		mounted () {
			this.getlist()
		},
		methods: {
			addbtn(){
				var data1 = {
					userMobile:this.phone,
					couponId:this.couponId
				}
				saveSpecificUcoupon(data1).then(res => {
					if(res.data.code==200){
						uni.showToast({
							title: '已发送优惠给指定用户',
							icon:"none"
						})
						this.coupons=!this.coupons
					}
					
				})
			},
			bindPickerChange: function(e) {
				this.couponId = this.array[e.detail.value].id
				this.couponname = this.array[e.detail.value].name
				this.couponvalue = this.array[e.detail.value].value
			},
			getlist(){
				let data1 = {}
				couponsQueryAll(data1).then(res => {
					this.array = res.data.data
				})
			}
		},
	}
</script>

<style scoped>
	.search-input{
		padding: 30rpx;
		margin: 20rpx;
		font-size: 30rpx;
	}
	input,.input{
		border: 1rpx solid #1296db;
		height: 70rpx;
		line-height: 70rpx;
		margin: 20rpx 0;
		border-radius: 6rpx;
		font-size: 32rpx !important;
		padding-left: 20rpx;
	}
	
</style>
 